class Solution
{
public:
    vector<int> kWeakestRows(vector<vector<int>> &mat, int k)
    {
        int m = mat.size();
        vector<int> strengths(m);
        for (int i = 0; i < m; ++i)
        {
            strengths[i] = find(mat[i].begin(), mat[i].end(), 0) - mat[i].begin();
        }
        vector<int> strengthIndex(m);
        iota(strengthIndex.begin(), strengthIndex.end(), 0);
        sort(strengthIndex.begin(), strengthIndex.end(), [&](int i, int j)
             {
            if(strengths[i] == strengths[j])
            {
                return i < j;
            }
            return strengths[i] < strengths[j]; });
        return {strengthIndex.begin(), strengthIndex.begin() + k};
    }
};